package com.gxa.service.Impl;

import com.gxa.POJO.AcComments;
import com.gxa.POJO.Scomments;
import com.gxa.common.base.RespResult;
import com.gxa.mapper.CommentsManagementMapper;
import com.gxa.service.CommentsManagementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/*
 *@Author:那我也
 *@Date:2023/4/10-18:27
 *@Description:
 */
@Service
public class CommentsManagementServiceImpl implements CommentsManagementService {
    @Autowired
    CommentsManagementMapper commentsManagementMapper;
    /*=========================1.服务评论查询（默认第一页，每页6条数据）=============================*/
    @Override
    public RespResult commentsFind(Map<String,Object> map) {
        try {
            List<Scomments> comments=commentsManagementMapper.selectCommentsByConditions(map);
                if (comments.size()>0){
                    return RespResult.success(comments);
                }else {
                    return RespResult.success("没有符合的数据");
                }
        } catch (Exception e) {
            e.printStackTrace();
            return RespResult.error("服务出错");
        }
    }
/*===========================================*/

    @Override
    public RespResult acCommentFind(Map<String,Object> map) {
        try {
            List<AcComments> comments=commentsManagementMapper.selectAcCommentsByConditions(map);
            if (comments.size()>0){
                return RespResult.success(comments);
            }else {
                return RespResult.success("没有符合的数据");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return RespResult.error("服务出错");
        }
    }
/*==============================================*/

    @Override
    public RespResult upAndDown(Integer AcId) {
        try {
            Integer row=commentsManagementMapper.updateStatus(AcId);
            if (row>0){
                return RespResult.success(row);
            }else {
                return RespResult.success("没有数据被修改！！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return RespResult.error("服务出错");
        }
    }
}
